package com.mc.music_web.controller;

import com.mc.music_web.entity.CD;
import com.mc.music_web.services.CdVoService;
import com.mc.music_web.vo.CDVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class CDController {

    @Autowired
    private CdVoService cdVoService;


    @RequestMapping("/admin/lastCD")
    public  String goCd(){

        return "/admin/cd";
    }

    @RequestMapping("/admin/cdList")
    @ResponseBody
    public List cdList(){
        List<CDVo> list=cdVoService.selectCDVo();
        return list;
    }

    @RequestMapping("/admin/cdDel")
    @ResponseBody
    public int delCD(Integer cdId) {
        int result = cdVoService.delCDVo(cdId);
        return result;
    }


    @RequestMapping("/admin/goCDUpdate")
    @ResponseBody
    public CD updateCD(Integer cdId) {

        CD cd = cdVoService.selectByPrimaryKeyCDVo(cdId);

        return cd;
    }


    @RequestMapping("/admin/doCDUpdate")
    @ResponseBody
    public CD doUpdateCD( CD cd) {

        cdVoService.updateCDVo(cd);
        return cd;
    }


 /*   @RequestMapping("/admin/goSongLimit")
    @ResponseBody
    public PageInfo selectSongLimit(int pageNum, HttpSession session) {
        PageInfo<Song> pageInfosO = songVoService.selectSongLimit(pageNum);
        session.setAttribute("songSession",pageInfosO);
        return pageInfosO;
    }*/






    @RequestMapping("/admin/addCDs")
    @ResponseBody
    public Integer addCD(CD cd){

        Integer i = cdVoService.insertCDVo(cd);
        return i;
    }


    @RequestMapping("/admin/adminByCd")
    @ResponseBody
    public  List  selectByChoose(String keyword){
        List<CDVo> list=cdVoService.selectByCD(keyword);
        return list;
    }
}
